**************************************************************
*** POLAT: recode

**************************************************************

* Note: save all waves in one folder first

cd "SET_YOUR_PATH\POLAT\Data"

use "PanelPOLAT_6waves_public_June_2018_v13-2.dta", clear



**********************
*** Recode data ******
**********************

gen pid = codpanelista2

lab var pid "Person-ID"
lab var wave "Wave"



*** financial
fre ecositpersonal income 

// personal economic situation
recode ecositpersonal (3=0 "worse")(1 2=1 "same or better")(else=.), gen(satinc)
recode ecositpersonal (3=0 "worse")(2=5 "same")(1=10 "better")(else=.), gen(satinc3)

lab var satinc "Satisfaction with personal economic situation"

// personal net income
fre income

recode income (1=150)(2=450)(3=750)(4=1050)(5=1500)(6=2100)(7=2700)(8=3750)(9=5250)(10=9000)(else=.), gen(inc_mean)
xtile inc_dec = inc_mean, nq(10) 
fre inc_dec


*** Political

// media use
foreach var of varlist tvradionews tvradiopolother paper internetpol {
	recode `var' (1=5 "every day")(2=4)(3=3)(4=2)(5=1 "never")(else=.), gen(`var'_r)
}

egen media_pol = rowmean(tvradionews_r tvradiopolother_r paper_r internetpol_r)
lab var media_pol "Use of media for news and politics"

// Political participation online
egen part_inet = anycount(onlinepetition onlinecontact onlinedonation onlineopemail onlineopinsocial onlineopblog), val(1)
lab var part_inet "Index: Political participation online"

// Political Interest
recode polintr (1=4 "strong")(2=3)(3=2)(4=1 "none")(else=.), gen(polint)
lab var polint "Political Interest"

	
// Internal Efficacy
clonevar inteff1 = efintunderstand
clonevar inteff2 = efintopinion

egen inteff = rowmean(inteff1 inteff2)
lab var inteff "Internal Efficacy Index"

// Duty to vote 
gen dutyintens_r = 4 - dutyintens
gen voteduty = dutyintens_r
replace voteduty = 0 if duty==2

lab var voteduty "Duty to vote (Intensity)"

// Party ID
recode partyid (1/50=1 "has PID")(55=0 "does not have PID")(else=.), gen(partyid01)
gen partyidintens_r = 4 - partyidintens

gen pidstr = partyidintens_r
replace pidstr = 0 if partyid01==0

lab var partyid01 "Has Party ID"
lab var pidstr "Party ID Strength"

// Probability to vote
clonevar voteprob = probvote
lab var voteprob "Probability to vote"


// Trust in political institutions        
clonevar trust_parl = trustparl
clonevar trust_gov = trustgov
clonevar trust_party = trustparty
clonevar trust_pol = trustpoliticians       

lab var trust_parl "Trust in parliament"
lab var trust_gov "Trust in government"
lab var trust_party "Trust in parties"
lab var trust_pol "Trust in politicians"


// Political participation
egen part_pol = anycount(petition boycott contact donate demons strike), val(1)
lab var part_pol "Index: Political participation"


*** Socio-Demographics
fre age sex education sitlab 

lab var age "Age"
gen age18 = age-18

gen female = sex-1
lab var female "Sex: Female"

recode education (1/5=0 "low")(6/11=1 "high"), gen(edu)

recode sitlab (4 5=1 "unemployed")(1/3 6/8=0 "else")(else=.), gen(unemployed)
recode sitlab (2 3 6 7=1 "nlf")(1 4 5 8=0 "else")(else=.), gen(nlf)






********************************************
** Recode variables to scale from 0-10
********************************************

foreach var of varlist satinc polint inteff voteduty pidstr voteprob trust_parl ///
		trust_gov trust_party trust_pol media_pol part_pol part_inet {
	sum `var'
	gen `var'10 = (`var' - r(min)) * (10/(r(max)-r(min)))
}



*******************************
*** Save long
*******************************

save polat_long, replace












